package com.wlys.player.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.widget.BaseExpandableListAdapter;
import android.widget.ImageView;

import com.wlys.player.WlysApplication;
import com.wlys.player.utils.imagecache.ImageFetcher;
import com.wlys.player.utils.imagecache.ImageWorker;

public abstract class BaseCacheExpandableListAdapter extends
        BaseExpandableListAdapter
{
    protected Context mContext;
    protected ImageWorker mImageWorker;
    protected LayoutInflater mInflater;
    
    public BaseCacheExpandableListAdapter(Context context)
    {
        super();
        mContext = context;
        mInflater = LayoutInflater.from(context);
    }

    public void setCacheImage(final ImageView imageView, String imageUrl,
            final int resId)
    {
        if (mImageWorker == null)
        {
            mImageWorker = new ImageFetcher(mContext,
                    WlysApplication.getLongest());
            mImageWorker.setImageCache(WlysApplication.getImageLruCache());
        }
        mImageWorker.setLoadingImage(resId);
        mImageWorker.loadImage(imageUrl, imageView);
    }

}
